﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DLV.Utilities;

namespace DLV.Data.Entities
{
    public class AgeController
    {
        public int InsertAge(AgeInfo info)
        {
            return SQL.InsertAge(info.AgeName, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status);
        }
        public void UpdateAge(AgeInfo info)
        {
            SQL.UpdateAge(info.AgeId, info.AgeName, info.CreatedBy, info.CreatedDate, info.UpdatedBy, info.UpdatedDate, info.Status);
        }
        public void DeleteAge(AgeInfo info)
        {
            DeleteAge(info.AgeId);
        }
        public void DeleteAge(int ageId)
        {
            SQL.DeleteAge(ageId);
        }
        public AgeInfo GetAge(int ageId)
        {
            return CBO.FillObject<AgeInfo>(SQL.GetAge(ageId));
        }
        public List<AgeInfo> ListAge()
        {
            return CBO.FillCollection<AgeInfo>(SQL.ListAge());
        }
        public DataTable SelectAge()
        {
            return CBO.ConvertToDataTable(ListAge(), typeof(AgeInfo));
        }
        public Dictionary<object, object> ListAgeLookup()
        {
            var users = ListAge();
            var dicusers = new Dictionary<object, object>();
            foreach (AgeInfo info in users)
                dicusers.Add(info.AgeId, info.AgeName);

            return dicusers;
        }
    }
}
